#include <iostream>
#include <map>
#include <string>

using namespace std;

#define MAX_LENGTH 75

typedef map <string, int> Conquest;

Conquest conquest;


int main ()
{
	int lines;
	string country;

	cin >> lines;
	while (lines--)
	{
		cin >> country;
		cin.ignore (75, '\n');
		++ conquest[country];
	}

	for (Conquest::iterator it = conquest.begin (); it != conquest.end (); ++it)
		cout << it->first << ' ' << it->second << '\n';

	return 0;
}